home *** CD-ROM | disk | FTP | other *** search
-
- #include <exec/types.h>
- #include <dos.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <string.h>
- #include <clib/exec_protos.h>
- #include <clib/dos_protos.h>
- #include "sc:ae/CmodGlue/glue.h"
- #include "sc:ae/CmodGlue/doorheader.h"
-
- void LastCommand(void);
- void end(void);
-
- #define sm sendmessage
- #define gu getuserstring
- #define sr StripReturn
-
- void StripReturn(char *s);
- int readbackwards(BPTR fi,char *string);
- void mysearch(char *filename,char *string);
-
- main(int argc,char *argv[])
- {
- int mynode;
- char temp[100];
- char location[100];
- if(argc!=2)
- exit(0);
- mynode=argv[1][0]-'0';
- Register(argv[1][0]-'0');
- gu(location,BB_LOCAL);
- sprintf(temp,"%sNode%d/callerslog",location,mynode);
- mysearch(temp,"****");
- ShutDown();
- end();
- }
-
- void LastCommand(void)
- {
- sm("",1);
- }
- void end(void)
- {
- exit(0);
- }
-
- void mysearch(char *filename,char *string)
- {
- BPTR fi;
- char image[190];
- fi=Open(filename,MODE_OLDFILE);
- if(fi)
- {
- Seek(fi,0L,OFFSET_END);
- if(readbackwards(fi,string))
- {
- while(FGets(fi,(UBYTE *)&image,180L)!=NULL)
- {
- sr(image); sm(image,1);
- }
- }
- else
- {
- sm("Error cannot locate text.",1);
- }
- Close(fi);
- }
- }
- int readbackwards(BPTR fi,char *string)
- {
- register int total=0;
- char str[180];
- while(1)
- {
- if(Seek(fi,-1L,OFFSET_CURRENT)==-1L) return(0);
-
- Read(fi,(APTR)&str[total],1L);
-
- if(str[total]!=string[total]) total=0;
- else
- {
- total++;
-
- if(string[total]=='\0')
- {
- Seek(fi,-1L,OFFSET_CURRENT); return(1);
- }
- }
- if(Seek(fi,-1L,OFFSET_CURRENT)==-1L) return(0);
- }
- }
-
- void StripReturn(char *s)
- {
- register int i;
- i=strlen(s)-1;
- while(i>-1)
- {
- if(*(s+i)<=32) *(s+i)='\0'; else break;
- i--;
- }
- }
-
-